﻿using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SMSTasker
{
    public partial class About : Form
    {
        public About()
        {
            InitializeComponent();
            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is Label)
                {
                    ctrl.Visible = false;
                }
            }
            Localize();
        }

        private void Localize()
        {
            label2.Text = Localizer.Instance.GetString("fmAbout.label2");
            label3.Text = Localizer.Instance.GetString("fmAbout.label3");
            label5.Text = Localizer.Instance.GetString("fmAbout.label5");
            label7.Text = Localizer.Instance.GetString("fmAbout.label7");
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void About_Load(object sender, EventArgs e)
        {
            lbVersion.Text = "v." + Assembly.GetExecutingAssembly().GetName().Version;
        }

        // Paints the background of the form with a GradientFill pattern.
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            // On Windows Mobile Pocket PC 2003, the call to GradientFill
            // fails with GetLastError() returning 87 (ERROR_INVALID_PARAMETER)
            // when e.Graphics is used.
            // Instead, fill into a bitmap and then draw that onto e.Graphics.
            Bitmap bm = new Bitmap(Width, Height);
            Graphics gr = System.Drawing.Graphics.FromImage(bm);

            GradientFill.Fill(
                gr,
                this.ClientRectangle,
                Color.White, Color.LightBlue,
                GradientFill.FillDirection.LeftToRight);
            e.Graphics.DrawImage(bm, 0, 0);
            foreach (Control ctrl in this.Controls)
            {
                if (ctrl is Label)
                {
                    ControlBitmapExtensions.DrawLabel(ctrl, e.Graphics);
                }
            }
            gr.Dispose();
            bm.Dispose();
        }
    }
}